package com.tang.Dao;
import com.tang.pojo.Book;
import java.util.List;
public class PageDao {
    public int calCountTotal(){
        BaseDao bd=new BaseDao();
        String sql="select count(*) from t_book;";
        int temp=(int)bd.queryforSingle(sql);
        return temp;
    }
    public List<Book> calitems(int pageNow, int pageSize){
        BaseDao bd=new BaseDao();
        String sql="select * from t_book limit ?,?;";
        int begin=(pageNow-1)*pageSize;
        return bd.queryforMul(Book.class,sql,begin,pageSize);
    }
    public int calCountTotalByPrice(int begin,int end){
        BaseDao bd=new BaseDao();
        String sql="select count(*) from t_book where price between ? and ?;";
        int temp=(int)bd.queryforSingle(sql,begin,end);
        return temp;
    }
    public List<Book> calitemsByPrice(int pageNow, int pageSize,int beginP,int endP){
        BaseDao bd=new BaseDao();
        String sql="select * from t_book where price between ? and ? limit ?,?;";
        int begin=(pageNow-1)*pageSize;
        return bd.queryforMul(Book.class,sql,beginP,endP,begin,pageSize);
    }
}
